var youtube = function(){

	var options = {
		player: null,
		domElement: $(this)[0],
		videoId: 'XSV-VtJfwRw',
		playerOptions: {
			height: $(this).height(),
			width: $(this).width(),
			autoPlay: 1,
			showControls: 0,
			volume: 80
		},
		onPlayerReady: function(event){},
		onVideoEnded: function(event){},
		onVideoPlaying: function(event){},
		onVideoPaused: function(event){},
		onError: function(msg){}
	}; 
	//merge the default options with the user defined ones
	$.extend(true, options, userOptions);
	var yt = {
	
	};
	
	return yt;

	/**** INIT ****/
	(function(){
		//When this has loaded ot will call the onYouTubePlayerAPIReady function which we override in this method
		$.getScript('http://www.youtube.com/apiplayer?enablejsapi=1&version=3');
	}();
	
	// Hook up to the ready Event and create the player object
	window.onYouTubePlayerAPIReady = function(){
		options.player = new YT.Player(options.domElement.id, {
			height: options.playerOptions.height,
			width: options.playerOptions.width,
			videoId: options.videoId,
			playerVars: { 
				'autoplay': options.playerOptions.autoPlay, 
				'controls': options.playerOptions.showControls
			},
			events: {
				'onReady': onPlayerReady,
				'onStateChange': onPlayerStateChange,
				'onError': onPlayerError
			}
        });
	};
}